package com.his.server.utils.dao;

import java.util.Enumeration;
import java.util.HashMap;
import java.util.Properties;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.his.server.utils.main.ClassTool;
import com.his.server.utils.main.EnvironmentProperties;

public class DAOConfig {
	
    private static final Log logger;
	private static Properties daoProperties = null;
	
	static 
    {
        logger = LogFactory.getLog(EnvironmentProperties.class);
    }
	
	public static synchronized HashMap Load() {
		
		HashMap map = new HashMap();
		
		daoProperties = EnvironmentProperties.getEproperties().getPropertyList().get(2);
		Enumeration em = daoProperties.keys();
		
		while (em.hasMoreElements()) {
			String iface = (String) em.nextElement();
			String impl = (String) daoProperties.getProperty(iface);
				
			try {
				
				Class iface_c = ClassTool.loadClass(iface);
				Class impl_c = ClassTool.loadClass(impl);
				
				map.put(iface_c, impl_c);
				
			} catch (ClassNotFoundException ex) {
				logger.debug("No Class Found");
			}
		}
		
		return map;
			
	}
}